<?
    class Datum_model extends Model{
        function Datum_model(){
            parent::Model();
        }

        function getData($field, $tabel, $where) {
            $this->db->select($field);
            $this->db->where($where);
            $query = $this->db->get($tabel);
            if ($query->num_rows() > 0) {
                if ($row = $query->row_array()) {
                    return $row[$field];
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
        
        function getDataAll($tabel, $where) {
        	//$this->db->select($field);
            $this->db->where($where);
            $query = $this->db->get($tabel);
            if ($query->num_rows() > 0) {
                if ($row = $query->row_array()) {
                    return $row;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }

        function getDataNA($tabel, $where) {
            if($where)
            $this->db->where($where);
            $query = $this->db->get($tabel);
            if ($query->num_rows() > 0) {
                if ($row = $query->row_array()) {
                    return $query->result_array();
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
        
        function getLatestData($field, $tabel, $where) {
            $this->db->select_max($field);
            $this->db->where($where);
            $query = $this->db->get($tabel);
            if ($query->num_rows() > 0) {
                if ($row = $query->row_array()) {
                    return $row[$field];
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
		
		function getFirstData($field, $tabel, $where) {
            $this->db->select_min($field);
            $this->db->where($where);
            $query = $this->db->get($tabel);
            if ($query->num_rows() > 0) {
                if ($row = $query->row_array()) {
                    return $row[$field];
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }

    }
?>